import { Component, EventEmitter, Output } from '@angular/core';
import { FieldMapConfig, MonitorBoardConfig } from 'src/components/scenarios/models';

@Component({
  selector: 'app-monitor-board-setting',
  templateUrl: './monitor-board-setting.component.html',
  styleUrl: './monitor-board-setting.component.scss'
})
export class MonitorBoardSettingComponent {

  sidebarVisible: boolean = false;
  cfg?: MonitorBoardConfig;
  @Output()
  onHide: EventEmitter<MonitorBoardConfig> = new EventEmitter();

  onEdit(cfg: MonitorBoardConfig) {
    this.cfg = { ...cfg };
    this.sidebarVisible = true;
  }
  onSidebarHide() {
    this.onHide.next(this.cfg!);
    this.cfg = undefined;
  }

  onFieldMapChange(fields: FieldMapConfig[]) {
    this.cfg!.Fields = fields;
  }
}
